from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get("http://localhost/ranzhi/www")

#<input type="text" name="account" id="account" value="" class="form-control" placeholder="请输入用户名">
#定位输入框
driver.find_element(By.ID,"account").send_keys("root")
#<input type="password" name="password" id="password" value="" class="form-control" placeholder="请输入密码">
#定位密码框
driver.find_element(By.ID,"password").send_keys("123456")
#<button type="submit" id="submit" class="btn btn-primary" data-loading="稍候...">登录</button>
#点击登录
driver.find_element(By.ID,"submit").click()
sleep(3)
#点击文本库
#<li id="s-menu-4" data-order="4" class=""><button data-toggle="tooltip" data-tip-class="s-menu-tooltip" data-placement="right" data-btn-type="menu" class="app-btn s-menu-btn open active" title="" data-id="4" data-original-title="文档"><img src="/ranzhi/www/theme/default/images/ips/app-doc.png" alt=""></button></li>
driver.find_element(By.ID,"s-menu-4").click()
#新建文档
#<iframe id="iframe-4" name="iframe-4" src="/ranzhi/www/sys/entry-visit-4.html" frameborder="no" allowtransparency="true" scrolling="auto" hidefocus="" style="width: 100%; height: 100%; left: 0px;"></iframe>
#跳转至frame页面
a = driver.find_element(By.ID,"iframe-4")
driver.switch_to.frame(a)
#点击进入jiaqi的文档库
#<a href="/ranzhi/www/doc/doc-browse-1.html" title="jiaqi的文档库">jiaqi的文档库</a>
driver.find_element(By.LINK_TEXT,"jiaqi的文档库").click()
sleep(1)
#点击创建文档
#<a href="/ranzhi/www/doc/doc-create-1-0-0.html" class="btn btn-primary"><i class="icon-plus"></i> 创建文档</a>
driver.find_element(By.LINK_TEXT,"创建文档").click()
sleep(2)
#点击上传文件
#<input type="file" name="files[]" class="fileControl" tabindex="-1" onchange="checkSize(this)">
#<input type="file" name="files[]" class="fileControl" tabindex="-1" onchange="checkSize(this)">
es = driver.find_elements(By.NAME,'files[]')
es[0].send_keys(r"D:\OneDrive.pdf")
es[1].send_keys(r"C:\Users\Jiaqi\Videos\屏幕录制\video.mp4")
sleep(5)
#点击退出登录
#<button id="showDesk" type="button" class="fullscreen-btn icon-desktop" data-id="home" data-toggle="tooltip" title="" data-original-title="桌面"></button>
#推出到最外层
driver.switch_to.default_content()
#<a href="javascript:void(0)" class="sign signout">签退</a>
driver.find_element(By.LINK_TEXT,"签退").click()
sleep(2)